{% extends 'base.html' %}

{% block title %}
{% if request.path == url_for('question.create') %}
发布问题 - 知疑
{% elif question and request.path ==  url_for('question.edit', id=question.id) %}
编辑问题 - 知疑
{% endif %}
{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-10">
        <div class="card form-card">
            <div class="card-header">
                <h4 class="mb-0">
                    {% if request.path ==  url_for('question.create') %}
                    发布问题
                    {% elif  question and  request.path ==  url_for('question.edit', id=question.id) %}
                    编辑问题
                    {% endif %}
                </h4>
            </div>
            <div class="card-body">
                <form method="post">
                    {{ form.hidden_tag() }}
                    
                    <div class="mb-3">
                        {{ form.title.label(class="form-label") }}
                        {% if form.title.errors %}
                            {{ form.title(class="form-control is-invalid") }}
                            <div class="invalid-feedback">
                                {% for error in form.title.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.title(class="form-control", placeholder="简洁明了的问题标题") }}
                            <div class="form-text">标题应简洁明了，能准确描述你的问题</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        {{ form.content.label(class="form-label") }}
                        {% if form.content.errors %}
                            {{ form.content(class="form-control is-invalid", rows=10) }}
                            <div class="invalid-feedback">
                                {% for error in form.content.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.content(class="form-control", rows=10, placeholder="详细描述你的问题...") }}
                            <div class="form-text">详细描述你的问题，包括你已经尝试过的解决方法</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        {{ form.tags.label(class="form-label") }}
                        {% if form.tags.errors %}
                            {{ form.tags(class="form-select is-invalid", multiple=true, size=5) }}
                            <div class="invalid-feedback">
                                {% for error in form.tags.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.tags(class="form-select", multiple=true, size=5) }}
                            <div class="form-text">按住Ctrl键可选择多个标签，选择合适的标签有助于你的问题被更多相关人士看到</div>
                        {% endif %}
                    </div>
                    
                    <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                        <a href="{{ url_for('main.index') }}" class="btn btn-outline-secondary">取消</a>
                        {{ form.submit(class="btn btn-primary") }}
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 